package org.xtown.bingluo.xtieba.appinfo;

import org.xtown.bingluo.xtieba.R;
import org.xtown.bingluo.xtieba.controllers.Controller;
import org.xtown.bingluo.xtieba.utils.LogUtlils;
import org.xtown.bingluo.xtieba.utils.StringUtils;

import android.content.Context;
import android.content.SharedPreferences;

public class SettingInfo {

	public static String m_autohorscreem_key;
	public static String m_checkupdate_key;
	public static String m_about_key;
	public static boolean m_autohorscreem_v;
	public static String m_page_size_v;
	public static String[] m_page_size_values;
	public static String m_page_size_key;
	private static String m_page_size_default_value;
	private static Boolean m_autohorscreem_default_value;

	public static void setSettingInfo(Context ctt) {
		// 获取设置界面PreferenceActivity中各个Preference的值
		m_autohorscreem_key = ctt.getResources().getString(
				R.string.autohorscreem_key);
		m_autohorscreem_default_value = false;
		m_page_size_key = ctt.getResources().getString(
				R.string.page_size_key);
		m_page_size_default_value = ctt.getResources().getString(R.string.page_size_default_value);
		m_page_size_values = ctt.getResources().getStringArray(
				R.array.page_size_value);
		m_checkupdate_key = ctt.getResources().getString(
				R.string.checkupdate_key);
		m_about_key = ctt.getResources().getString(R.string.about_key);
		// 取得属于整个应用程序的SharedPreferences
		SharedPreferences settings = Controller.getInstance().getPreferences();
		m_autohorscreem_v = settings.getBoolean(m_autohorscreem_key, m_autohorscreem_default_value);
		m_page_size_v = settings.getString(m_page_size_key, m_page_size_default_value);
		LogUtlils.println("m_page_size_v="+m_page_size_v);
		if (!(StringUtils.isNumeric(m_page_size_v) && StringUtils.asNumber(m_page_size_v, Integer.valueOf(m_page_size_values[0])) <= Integer.valueOf(m_page_size_values[m_page_size_values.length-1])
		&& StringUtils.asNumber(m_page_size_v, Integer.valueOf(m_page_size_values[0])) >= Integer.valueOf(m_page_size_values[0]))
		) {
			m_page_size_v = m_page_size_values[0];
		}
		LogUtlils.println("m_page_size_v="+m_page_size_v);
	}

}
